#!/bin/bash

# 检测系统类型并执行相应的爱快安装脚本

# 函数：检测系统类型
detect_system() {
    if [ -f /etc/os-release ]; then
        # 读取系统信息
        . /etc/os-release
        case $ID in
            ubuntu)
                echo "检测到系统为 Ubuntu"
                return 1
                ;;
            centos|rhel|fedora)
                echo "检测到系统为 CentOS/RHEL/Fedora"
                return 2
                ;;
            *)
                echo "未知系统: $ID"
                return 0
                ;;
        esac
    elif [ -f /etc/redhat-release ]; then
        echo "检测到系统为 CentOS/RHEL"
        return 2
    else
        echo "无法检测系统类型"
        return 0
    fi
}

# 主函数
main() {
    detect_system
    system_type=$?
    
    case $system_type in
        1)
            echo "正在执行 Ubuntu 安装脚本..."
            bash -c "$(curl -fsSL https://gitee.com/mfkd1000/ik/raw/master/ubuntu_install_ikuai8.sh)"
            ;;
        2)
            echo "正在执行 CentOS 安装脚本..."
            bash -c "$(curl -fsSL https://gitee.com/mfkd1000/ik/raw/master/centos_install_ik.sh)"
            ;;
        *)
            echo "不支持的系统类型，脚本退出"
            exit 1
            ;;
    esac
}

# 执行主函数
main